import {
	getPlanLineSectionSiteStateTreeByLike, //树形列表
	diseaseOrderGetList, //列表数据
	getLastFillingRecord,
	diseaseStatusList, //病害现状
	diseaseKeywordsList, //病害等级
	diseaseOrderGetDetails, //病害详情
	getDetailsList,	//所有的详情列表
} from '@/api/engineeringMaintenance/engineeringMaintenance.js'
import {
	diseaseMaterialList, // 物料描述
} from '@/api/engineeringMaintenance/maintenanceTask.js'
import {getDictMap}  from "@/api/system/dictionary.js"
import {
	doCache
} from '@/utils/offline/index.js'
import {
		getPicture
} from '@/api/doc.js' //获取图片
const currPage = 1;
const pageSize = 9999
//区间/站点缓存数据
export async function initCache() {
	return await doCache(getPlanLineSectionSiteStateTreeByLike, {
		projectId: uni.getStorageSync('isOwner'),
		type: 'inspect',
		projectStates:["zj","zt"],
	})
}
//字典表缓存数据
export async function dictionaryCache() {
	return await doCache(getDictMap)
}
//上次填报记录
export async function lastRecord(lineId,lineSiteSectionId,lineSiteSectionType) {
	return await doCache(getLastFillingRecord, {lineId,lineSiteSectionId,lineSiteSectionType})
}
//病害现状缓存
export async function cacheStatus() {
	return await doCache(diseaseStatusList, {
		currPage,
		pageSize,
		params: {
			projectId: uni.getStorageSync('isOwner'),
			keyword: '',
		}
	})
}
//病害关键字缓存
export async function cacheLevels() {
	return await doCache(diseaseKeywordsList, {
		currPage,
		pageSize,
		params: {
			projectId: uni.getStorageSync('isOwner'),
			keyword: ''
		}
	})
}
//修复措施缓存数据
export async function RepairMeasure() {
	return await doCache(diseaseMaterialList, {
		currPage,
		pageSize,
		params: {
			projectId: uni.getStorageSync('isOwner'),
			queryStr: ''
		}
	})
}

//缓存列表数据
export async function cacheOrderList() {
	return await doCache(diseaseOrderGetList, {
		currPage,
		pageSize,
		params: {
			type: 'inspect',
			// params:JSON.parse(uni.getStorageSync('lineData'))
		}
	})
}

//缓存详情数据
export async function detailList(id) {
	return await doCache(diseaseOrderGetDetails, {id})
}
//缓存详情数据（所有的详情数据）   
export async function allDetailData(obj) {
	return await doCache(getDetailsList, {
		lineId:obj.lineId,
		lineSiteSectionId:obj.lineSiteSectionId,
		lineSiteSectionType:obj.lineSiteSectionType
	})
}

//缓存图片数据
export async function cache_imgs(docId) {
	return await doCache(getPicture, {docId},docId)
}

